// +----------------------------------------------------------------------
// | JavaWeb_Cloud_Ant微服务旗舰版框架 [ JavaWeb ]
// +----------------------------------------------------------------------
// | 版权所有 2019~2020 南京JavaWeb研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.javaweb.vip/
// +----------------------------------------------------------------------
// | 作者: 鲲鹏 <1175401194@qq.com>
// +----------------------------------------------------------------------

package com.javaweb.service.system.controller;

import com.javaweb.common.framework.common.BaseController;
import com.javaweb.common.framework.utils.JsonResult;
import com.javaweb.service.system.entity.Example3;
import com.javaweb.service.system.query.Example3Query;
import com.javaweb.service.system.service.IExample3Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 演示案例表 前端控制器
 * </p>
 *
 * @author 鲲鹏
 * @since 2021-05-13
 */
@RestController
@RequestMapping("/example3")
public class Example3Controller extends BaseController {

    @Autowired
    private IExample3Service example3Service;

    /**
     * 获取数据列表
     *
     * @param example3Query 查询条件
     * @return
     */
    @PreAuthorize("@jw.hasPermission('sys:example3:index')")
    @GetMapping("/index")
    public JsonResult index(Example3Query example3Query) {
        return example3Service.getList(example3Query);
    }

    /**
     * 添加记录
     *
     * @param entity 实体对象
     * @return
     */
    @PreAuthorize("@jw.hasPermission('sys:example3:add')")
    @PostMapping("/add")
    public JsonResult add(@RequestBody Example3 entity) {
        return example3Service.edit(entity);
    }

    /**
     * 获取详情
     *
     * @param example3Id 记录ID
     * @return
     */
    @GetMapping("/info/{example3Id}")
    public JsonResult info(@PathVariable("example3Id") Integer example3Id) {
        return example3Service.info(example3Id);
    }

    /**
     * 更新记录
     *
     * @param entity 实体对象
     * @return
     */
    @PreAuthorize("@jw.hasPermission('sys:example3:edit')")
    @PutMapping("/edit")
    public JsonResult edit(@RequestBody Example3 entity) {
        return example3Service.edit(entity);
    }

    /**
     * 删除记录
     *
     * @param example3Ids 记录ID
     * @return
     */
    @PreAuthorize("@jw.hasPermission('sys:example3:delete')")
    @DeleteMapping("/delete/{example3Ids}")
    public JsonResult delete(@PathVariable("example3Ids") Integer[] example3Ids) {
        return example3Service.deleteByIds(example3Ids);
    }

    /**
     * 设置状态
     *
     * @param entity 实体对象
     * @return
     */
    @PreAuthorize("@jw.hasPermission('sys:example3:status')")
    @PutMapping("/setStatus")
    public JsonResult setStatus(@RequestBody Example3 entity) {
        return example3Service.setStatus(entity);
    }
}